package uk.ac.cam.tcs40.sidnet;

import java.util.Locale;

import uk.ac.cam.tcs40.sidnet.formal.FormalListFragment;
import uk.ac.cam.tcs40.sidnet.menu.MenuFragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class MainPagerAdapter extends FragmentPagerAdapter {

	public MainPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int position) {
		// getItem is called to instantiate the fragment for the given page.
		// Return a DummySectionFragment (defined as a static inner class
		// below) with the page number as its lone argument.
		Fragment fragment;

		switch (position) {
		case 0:
			fragment = new MenuFragment();
			break;
		case 1:
			fragment = new FormalListFragment();
			break;
		default:
			fragment = null;
		}

		return fragment;
	}

	@Override
	public int getCount() {
		// Show 2 total pages.
		return 2;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		Locale l = Locale.getDefault();
		switch (position) {
		case 0:
			return "Menu".toUpperCase(l);
		case 1:
			return "Formal".toUpperCase(l);
		}
		return null;
	}
}
